<template>
  <!--  合理性指标-->
  <div class="wrapper">
    <iframe
      id="reportFrame"
      style="padding: 0px; width: 100%; height: 1000px;"
      :src="urlJson"
    />
    <div>{{ urlJson }}</div>
    <div>
      <el-button type="primary" @click="ind_recipe">测试按钮</el-button>
      <el-button type="primary" @click="handleDownloadExcel">下载按钮</el-button>
      <el-button type="primary" @click="handleDownloadExcel2">取消</el-button>
    </div>
    <div>
      <table
        border="1"
        width="90%"
        cellspacing="0"
        cellpadding="0"
        style="border-collapse: collapse"
      >
        <tr height="50">
          <th colspan="5">全院合理用药指标表</th>
        </tr>
        <tr style="text-align: left;">
          <th colspan="5">医疗机构：1</th>
        </tr>
        <tr>
          <th colspan="3" style="text-align: left;">制表人：管理员</th>
          <th colspan="2" style="text-align: right;">制表时间：2020-06-02</th>
        </tr>

        <tr style="text-align: center;">
          <th colspan="1" rowspan="2">排名</th>
          <th colspan="1" rowspan="2">指标名称</th>
          <th colspan="1" rowspan="2">指标值</th>
          <th colspan="1">分子名称</th>
          <th colspan="1">分子值</th>
        </tr>
        <tr>
          <th colspan="1">分母名称</th>
          <th colspan="1">分母值</th>
        </tr>
        <template v-for="(item,index) in res">
          <tr :key="index" style="text-align: center;">
            <td colspan="1" rowspan="2">{{ index + 1 }}</td>
            <td colspan="1" rowspan="2">{{ item.indgroupName }}</td>
            <td colspan="1" rowspan="2">{{ item.indValue }}</td>
            <td colspan="1">{{ item.fzName }}</td>
            <td colspan="1">{{ item.fzValue }}</td>
          </tr>
          <tr :key="index" style="text-align: center;">
            <td colspan="1">{{ item.fmName }}</td>
            <td colspan="1">{{ item.fmValue }}</td>
          </tr>
        </template>

      </table>
    </div>
  </div>
</template>

<script>
import { ind_recipe } from '@/api/prc'
export default {
  name: 'RationalityIndex',
  data() {
    return {
      res: {},
      src1: "/ReportServer?reportlet=WorkBook1.cpt&data={'chargeTimeStart':'2019-02','chargeTimeEnd':'2025-02','indgroupName':'','queryCategory':'1','patientType':[2,3],'detectionType':1,'groupType':1,'hospital_code':0,'header':'111aa','lister':'22aa','tabTime':'33aa','medical':'44aa'}",
      src2: 'https://',
      src3: 'www.baidu.com/',

      urlserver: 'http://yuwenbincl.xicp.net:19133/ReportServer?reportlet=',
      urlcpt: 'WorkBook1', // cpt文件名
      urldata: '.cpt&data=',
      queryJson: {
        chargeTimeStart: '2011-02',
        chargeTimeEnd: '2025-02',
        indgroupName: '',
        queryCategory: '1',
        patientType: [2, 3],
        detectionType: 1,
        groupType: 1,
        hospital_code: 0,
        header: 'ce',
        lister: 'bbbbbb',
        tabTime: 'cccccccccc',
        medical: '11111111' },
      urlJson: '',
      urlJson2: 'http://yuwenbincl.xicp.net:19133/ReportServer?reportlet=WorkBook1.cpt&data=' +
        "{'chargeTimeStart':'2011-02','chargeTimeEnd':'2025-02','indgroupName':'','queryCategory':'1'," +
        "'patientType':[2,3],'detectionType':1,'groupType':1,'hospital_code':0,'header':'AAAAAAAAA'," +
        "'lister':'bbbbbb','tabTime':'cccccccccc','medical':'11111111'}",

      jsonss: '',
      tableData: [
        {
          data11: '数据11',
          data12: '数据112',
          data13: '数据113',
          data14: '数据114',
          data15: '数据115',
          data16: '数据116',
          data17: '数据176',
          data18: '数据177',
          index: 1
        },
        {
          data11: '数据21',
          data12: '数据22',
          data13: '数据23',
          data14: '数据24',
          data15: '数据25',
          data16: '数据26',
          data17: '数据27',
          data18: '数据29',
          index: 2
        }
      ]
    }
  },
  methods: {
    handleDownloadExcel() {
      this.src4 = this.src2 + this.src3
      // this.urlJson = this.urlserver + this.urlcpt + this.urldata + JSON.stringify(this.queryJson)
      this.urlJson = this.urlJson2
    },
    handleDownloadExcel2() {
      this.urlJson = ''
    },
    formatJson(filterVal, jsonData) {
      return jsonData.map(v =>
        filterVal.map(j => {
          if (j === 'timestamp') {
            return parseTime(v[j])
          } else {
            return v[j]
          }
        })
      )
    },

    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 0 || columnIndex === 1 || columnIndex === 2) {
        if (rowIndex % 2 === 0) {
          return {
            rowspan: 2,
            colspan: 1
          }
        } else {
          return {
            rowspan: 0,
            colspan: 0
          }
        }
      }
    },
    async ind_recipe() {
      await ind_recipe(
        JSON.stringify({
          chargeTimeStart: '2017-01-01',
          chargeTimeEnd: '2020-01-01',
          indgroupName: '门(急)诊病人指标',
          queryCategory: 3
        })
      ).then(res => {
        console.log(res)
        this.res = res
      }).catch(err => {
        console.log(err)
      })
    }
  }
}
</script>

<style scoped>
</style>
